1. /* simshift.cpp by K.Tsuru */
  2. // function ID = 410 BRADIX
  3. /**********************************************
  4. SInteger class
  5. It provides a bit shift i.e. multiplies by 2^p.
  6. Both cases p>0 and p<0 are allowed.
  7. example : 2^1000
  8. SLong L;
  9. SInteger d(1);
  10. d.BitShift(1000L);
  11. L = d.ConvToDec();
  12. ***********************************************/
  13. #ifndef SN_H
  14. #include "sn.h"
  15. #endif
  16. SInteger& SInteger::BitShift(long p){
  17. if(!p || !Sign(413)) return *this;
  18. long n = p/(long)BRADIX_BITS, r = p-(long)BRADIX_BITS*n;
  19. if(r < 0){
  20. r += BRADIX_BITS; n--;
  21. }
  22. ulong mul = 1uL << (int)r;
  23. if(r) IsMult(*this, mul, *this);
  24. //When n < 0 and it becomes zero, "SetZero()" is executed in the function "ShiftArray()".
  25. ShiftArray((int)n);
  26. return *this;
  27. }

simshift.cpp : last modifiled at 2015/12/14 16:11:09(767 bytes)
created at 2016/04/25 14:53:17
The creation time of this html file is 2017/10/25 11:09:45 (Wed Oct 25 11:09:45 2017).